//deleteAction
import request from '@/utils/request'

export function deleteAction(url, parameter) {
  return axios({
    url: url,
    method: 'delete',
    data: parameter,
  })
}
//get
// export function getAction(url, parameter) {
//   // let sign = signMd5Utils.getSign(url, parameter)
//   //将签名和时间戳，添加在请求接口 Header
//   // update-begin--author:taoyan---date:20220421--for: VUEN-410【签名改造】 X-TIMESTAMP牵扯
//   // let signHeader = { 'X-Sign': sign, 'X-TIMESTAMP': signMd5Utils.getTimestamp() }
//   // update-end--author:taoyan---date:20220421--for: VUEN-410【签名改造】 X-TIMESTAMP牵扯

//   return axios({
//     url: url,
//     method: 'get',
//     data: parameter,
//     headers: signHeader,
//   })
// }

/**
 * 下载文件 用于excel导出
 * @param url
 * @param parameter
 * @returns {*}
 */
export function downFile(url, parameter, method = 'get') {
  if (method == 'get') {
    return axios({
      url: url,
      data: parameter,
      method: method,
      responseType: 'blob',
    })
  } else {
    return axios({
      url: url,
      method: method,
      data: parameter,
      responseType: 'blob',
    })
  }
}
/**
 * 获取文件服务访问路径
 * @param avatar
 * @param subStr
 * @returns {*}
 */
export function getFileAccessHttpUrl(avatar, subStr) {
  if (!subStr) subStr = 'http'
  try {
    if (avatar && avatar.startsWith(subStr)) {
      return avatar
    } else {
      if (avatar && avatar.length > 0 && avatar.indexOf('[') == -1) {
        return window._CONFIG['staticDomainURL'] + '/' + avatar
      }
    }
  } catch (err) {
    return
  }
}

/**
 * 上传图片
 */
export function deleteImgFile(params) {
  return request({ url: `/vietnam-travel-admin/images/v1/delete`, method: 'get', data: params})
}
